var BatchImagesDownloader = {
  show : function() {
    var doc = window.getBrowser().selectedBrowser.contentDocument;
	var imageNodes = doc.getElementsByTagName("img");
	var params = {"imageNodes" : imageNodes};
    this.openOrFocusWindow("BatchImagesDownloader.mainWindow", "chrome://batchimagesdownloader/content/mainWindow.xul", "chrome=yes,centerscreen", params);
  },
  
  openOrFocusWindow : function(windowName, url, flags, params) {
    var windowsMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
    var win = windowsMediator.getMostRecentWindow(windowName);
    if (win)
      win.focus();
    else
      win = window.openDialog(url, windowName, flags, params);
    return win;
  },
};